<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" layout:decorator="index">
<head>
<meta charset="UTF-8"/>
<title>Insert title here</title>

<!-- 引入 Bootstrap -->
   <link   href="../../static/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"></link>
     <!--springboot默认路径-->
   <link href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"></link>
<!--自己的样式-->
    <link href="location.css" rel="stylesheet"></link>
    <link href="../../static/location.css" rel="stylesheet"></link>
   <!-- HTML5 Shiv 和 Respond.js 用于让 IE8 支持 HTML5元素和媒体查询 -->
   <!-- 注意： 如果通过 file://  引入 Respond.js 文件，则该文件无法起效果 -->
   <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
   <![endif]-->
   <!-- jQuery (Bootstrap 的 JavaScript 插件需要引入 jQuery) -->
    <script src="https://code.jquery.com/jquery.js"></script>
    <!-- 包括所有已编译的插件 -->
    <script src="../../static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <!--springboot默认路径-->
    <script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>

<script type="text/javascript">
//checkbox 全选/取消全选
       var isCheckAll = false;
       function swapCheck() {
           if (isCheckAll) {
               $("input[type='checkbox']").each(function() {
                   this.checked = false;
               });
               isCheckAll = false;
           } else {
               $("input[type='checkbox']").each(function() {
                   this.checked = true;
               });
               isCheckAll = true;
           }
}


function deleteuser(){
  const deleteArray=new Array();
  $("input[name='userid']").each(function() {
      if(this.checked){
        deleteArray.push(this.value);
      }
  });
alert(JSON.stringify(deleteArray));
  $.ajax({
  	    type : 'post',
  	    contentType : 'application/json',
  	    url : 'http://localhost:8888/top/deleteModule',
  	    processData : false,
  	    dataType : 'JSON',
  	    data :JSON.stringify(deleteArray),
  	    success : function(message) {
  	        alert(message );
            document.location.reload();
  	    },
  	    error : function() {
  	        alert('Err...');
  	    }
  	});
  console.log(deleteArray);
}


      </script>








</head>
<body>
<div layout:fragment="content" class="content">

  <ol class="breadcrumb" th:object="${funplace}">
	  <li th:text="*{funplace1}"><a href="#" >系统管理</a></li>
	  <li th:text="*{funplace2}"><a href="#" >用户管理</a></li>
	  <li th:text="*{funplace3}" class="active" >用户添加</li>
 </ol>
      <table class="table">

      <thead>
          <button id="fat-btn" class="btn btn-primary"  type="button" onclick="deleteuser()"> 删除选中</button>
          <button id="fat-btn" class="btn btn-success"  type="button"> <a href="/top/addModule" class="addstyle">添加顶层模块</a></button>
        <tr >
          <th>
          <label class="checkbox-inline">
              <input type="checkbox" id="inlineCheckbox1" value="option1" onclick="swapCheck()"/> 全选
          </label>
          </th>
          <span th:each="title : ${titles}">
          <th th:text="${title}"  >真实姓名</th>
          </span>
          <span >
          <th  >操作</th>
          </span>
        </tr>
      </thead>
      <tbody>

        <tr class="success" th:each="List : ${List}">
          <th>
          <label class="checkbox-inline">
              <input type="checkbox" class="deleteid" name="userid" value="1"  th:value="${List.id}"  />
          </label>
          </th>
          <td th:text="${List.id}">小虎</td>
          <td th:text="${List.modulename}">小虎</td>
          <td th:text="${List.modulenote}">小虎</td>
          <td><a  href="update/moduleupdate.html"  th:href="@{/top/updateModule(id=${List.id})}">查看&amp;修改</a>||
              <a   th:href="@{/top/deleteModule(id=${List.id})}"> 删除</a>

          </td>

        </tr>


      </tbody>



    </table>


      <div class="pagestyle">
        <ul class="pager">
          <li th:if="${number==0}"  class="disabled"><a href="">上一页</a></li>
        	<li th:if="${number != 0}"><a href="#"  th:href="@{/user/getusers(pageinfo=${number}-1)}" >上一页</a></li>
          <li class="disabled"><a href="#">当前 第<span th:text="${number}+1">5</span>页/共<span th:text="${pages}">10</span>页</a></li>
        	<li th:if="${number==pages-1}"  class="disabled"><a href="">下一页</a></li>
          <li th:if="${number!=pages-1}"  ><a href="#"  th:href="@{/user/getusers(pageinfo=${number}+1)}">下一页</a></li>
        </ul>
      </div>
</div>
</body>
</html>
